home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Delphi Programmer's Power Pack
/
Delphi Volume 1.iso
/
e_to_l
/
fbuilder
/
vb
/
fbcalc.bas
Wrap
BASIC Source File
|
1996-09-15
|
10KB
|
256 lines
'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
'
' FORMULABUILDER Version 1.0
' An Advanced Expression Parsing/Evaluation Engine
' Copyright (c) 1995 Clayton Collie, All Rights Reserved
'
' Published by YGB Software, Inc.
' Contact us via e-mail at 103515.1757@compuserve.com
'
' Or Write us at
'
' 161 Pearl St.
' Paterson, NJ 07501
' USA
'
'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
':::::::::::: VB Header for Formula Builder DLL :::::::::::::::::::::
Option Explicit
Global Const MAXFUNCPARAMS = 16 'Functions can have up to MAXFUNCPARAMS parameters
Global Const vtINTEGER = 0
Global Const vtBOOLEAN = 1
Global Const vtCHAR = 2
Global Const vtFLOAT = 3
Global Const vtSTRING = 4
Global Const vtDATE = 9
Global Const vtBOOL = 10
Global Const vtNONE = 13
Global Const vtTypeClash = 14
Global Const vtTypeMismatch = vtTypeClash
'*
'* Error Codes
'*
Global Const INVALID_VARIABLE = -9999 '* Arbitrary but (hopefully) unique
Global Const EXPR_SUCCESS = 1
Global Const EXPR_MISSING_PAREN = 2
Global Const EXPR_BAD_EXPRESSION = 3
Global Const EXPR_BAD_ASSIGNMENT = 4
Global Const EXPR_UNKNOWN_IDENT = 5
Global Const EXPR_LINE_TOO_LONG = 6
Global Const EXPR_INVALID_TOKEN = 7
Global Const EXPR_INVALID_CHAR = 8
Global Const EXPR_MISSING_PARAM = 9
Global Const EXPR_TYPE_MISMATCH = 10
Global Const EXPR_INVALID_NUMBER = 11
Global Const EXPR_MISSING_VARIABLE = 12
Global Const EXPR_INVALID_VARIABLE = 12
Global Const EXPR_INVALID_FUNCTION = 13
Global Const EXPR_ZERO_DIVISION = 14
Global Const EXPR_STACK_OVERFLOW = 15
Global Const EXPR_UNEXPECTED_EOS = 16
Global Const EXPR_INVALID_DATE = 17
Global Const EXPR_IDENTIFIER_EXPECTED = 18
Global Const EXPR_RANGE_ERROR = 19
Global Const EXPR_DOMAIN_ERROR = 20
Global Const EXPR_MATH_ERROR = 21
Global Const EXPR_FP_OVERFLOW = 22
Global Const EXPR_FP_UNDERFLOW = 23
Global Const EXPR_INT_OVERFLOW = 24
Global Const EXPR_INVALID_OP = 25
Global Const EXPR_VARIABLE_EXPECTED = 26
Global Const EXPR_MISSING_OPERATOR = 27
Global Const EXPR_MISSING_OPERAND = 28
Global Const EXPR_CONSTANT_EXPECTED = 29
Global Const EXPR_DUPLICATE_IDENT = 30
Global Const EXPR_SYNTAX_ERROR = 31
Global Const EXPR_CONVERT_ERROR = 32
Global Const EXPR_INVALID_TYPE = 33
Global Const EXPR_INVALID_HANDLE = 50
Global Const EXPR_INVALID_CALLBACK = 51
Global Const EXPR_FORMULA_TOO_COMPLEX = 54
':::::::::::::::Engine initialization and shutdown:::::::::::::
Declare Function FBInitExpression& Lib "FBCALC.DLL" (ByVal Exprdata&)
Declare Function FBFreeExpression% Lib "FBCALC.DLL" (ByVal handle&)
'::::::::::::::::::::: Expression Manipulation ::::::::::::::::::::
Declare Function FBSetExpression% Lib "FBCALC.DLL" (ByVal handle&, ByVal expr$)
Declare Function FBReparseExpression% Lib "FBCALC.DLL" (ByVal handle&)
Declare Function FBClearExpression% Lib "FBCALC.DLL" (ByVal handle&)
Declare Function FBGetExpression% Lib "FBCALC.DLL" (ByVal handle&, ByVal lpszResult$, ByVal maxlen%)
'::::::::::::::::::::: Expression Evaluation :::::::::::::::::::::::
'******************************************************************
'determine the result type of the expression. Returns one of the
' vtXXX constants, vtTYPEMISMATCH for an invalid expression
'******************************************************************
Declare Function FBGetReturnType% Lib "FBCALC.DLL" (ByVal handle&)
'*********************************************************************
' Evaluate the expression, returning a maximum of maxlen characters
' of the null-terminated string result in the buffer/string pointed to
' by outbuf
'**********************************************************************
Declare Function FBEvaluate% Lib "FBCALC.DLL" (ByVal handle&, ByVal outbuf$, ByVal maxlen%)
'*
'* Get Results in native types
'*
Declare Function FBGetStringResult% Lib "FBCALC.DLL" (ByVal handle&, ByVal value$, ByVal maxlen)
Declare Function FBGetFloatResult% Lib "FBCALC.DLL" (ByVal handle&, value#)
Declare Function FBGetBooleanResult% Lib "FBCALC.DLL" (ByVal handle&, value%)
Declare Function FBGetIntResult% Lib "FBCALC.DLL" (ByVal handle&, value&)
Declare Function FBGetDateResult% Lib "FBCALC.DLL" (ByVal handle&, value#)
'*************************************************************************
' Perform a single operation expression evaluation. This is not the most
' efficient method of evaluation when the expression remains the same
'*************************************************************************
Declare Function EvalExpression% Lib "FBCALC.DLL" (ByVal expr$, retType%, ByVal buf$, ByVal maxlen%)
' ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::}
' Internal Variable handling routines. NOTE ! If the variable callbacks are }
' implemented, the evaluation engine will not see the variables added }
' by FBAddvariable }
' ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::}
' Add a variable of type Vtype (see vtXXX constants) to the Expression Engine
Declare Function FBAddVariable% Lib "FBCALC.DLL" (ByVal handle&, ByVal varname$, ByVal vtype%)
'******************************************************************
'Parse the string expression expr, and create a variable with its
'type and value
'******************************************************************
Declare Function FBParseAddVariable% Lib "FBCALC.DLL" (ByVal handle&, ByVal vname$, ByVal expr$)
'*
'* Set the value of variable vname from the string value
'*
Declare Function FBSetVarFromString% Lib "FBCALC.DLL" (ByVal handle&, ByVal vname$, ByVal value$)
Declare Function FBSetStringVariable% Lib "FBCALC.DLL" (ByVal handle&, ByVal vname$, ByVal value$)
Declare Function FBSetIntegerVariable% Lib "FBCALC.DLL" (ByVal handle&, ByVal vname$, ByVal value&)
Declare Function FBSetFloatVariable% Lib "FBCALC.DLL" (ByVal handle&, ByVal vname$, ByVal value#)
Declare Function FBSetBooleanVariable% Lib "FBCALC.DLL" (ByVal handle&, ByVal vname$, ByVal value%)
Declare Function FBSetDateVariable% Lib "FBCALC.DLL" (ByVal handle&, ByVal vname$, ByVal value#)
'*
'* Get Variable Values
'*
Declare Function FBGetVarAsString% Lib "FBCALC.DLL" (ByVal handle&, ByVal vname$, ByVal value$, ByVal maxlen%)
Declare Function FBGetStringVariable% Lib "FBCALC.DLL" (ByVal handle&, ByVal vname$, ByVal value$, ByVal maxlen%)
Declare Function FBGetIntegerVariable% Lib "FBCALC.DLL" (ByVal handle&, ByVal vname$, value&)
Declare Function FBGetFloatVariable% Lib "FBCALC.DLL" (ByVal handle&, ByVal vname$, value#)
Declare Function FBGetBooleanVariable% Lib "FBCALC.DLL" (ByVal handle&, ByVal vname$, value%)
Declare Function FBGetDateVariable% Lib "FBCALC.DLL" (ByVal handle&, ByVal vname$, value#)
Declare Function FBPeekVarVB% Lib "FBCALC.DLL" (ByVal handle&, ByVal vno%, ByVal vname$, ByVal maxnamelen%, vtype%, ByVal value$, ByVal maxvallen%)
Declare Function FBFreeVariable% Lib "FBCALC.DLL" (ByVal handle&, ByVal vname$)
Declare Function FBFreeVariableList% Lib "FBCALC.DLL" (ByVal handle&)
Declare Function FBGetVariableCount% Lib "FBCALC.DLL" (ByVal handle&)
':::::::::::::::::::::::: CONSTANTS :::::::::::::::::::::::::::::::::::'
Declare Function FBParseAddConst% Lib "FBCALC.DLL" (ByVal vname$, ByVal expr$)
Declare Function FBAddStringConstant% Lib "FBCALC.DLL" (ByVal cname$, ByVal value$)
Declare Function FBAddDateConstant% Lib "FBCALC.DLL" (ByVal cname$, ByVal value#)
Declare Function FBAddNumericConstant% Lib "FBCALC.DLL" (ByVal cname$, ByVal value#)
Declare Function FBAddBooleanConstant% Lib "FBCALC.DLL" (ByVal cname$, ByVal value%)
Declare Function FBFreeConstant% Lib "FBCALC.DLL" (ByVal cname$)
Declare Function FBFreeConstants% Lib "FBCALC.DLL" ()
Declare Function FBGetConstAsString% Lib "FBCALC.DLL" (ByVal handle&, ByVal cname$, ByVal value$, ByVal maxlen%)
'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::